package com.trying.simpleioc.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;
/**
 * 属性操作工具
 * @author dimi
 *
 */
public class PropertiesUtil {

	private static final Logger log=Logger.getLogger(ReflectionUtil.class);

	private PropertiesUtil(){}
	/**
	 * 加载属性文件
	 * @param fileName
	 * @return
	 */
	public static Properties load(String fileName){
		Properties pro=null;
		InputStream in=null;
		
		try {
			in=Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
			
			if(in==null){
				throw new FileNotFoundException("The file :"+fileName+" is not found.");
			}
			pro=new Properties();
			pro.load(in);
		} catch (IOException e) {
			log.error(e);
		}finally{
			CloseableUtil.close(in);
		}
		return pro;
	}
}
